package com.example.cuilei.kblight.util;

import android.content.Context;

import com.example.cuilei.kblight.shell.ShellBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Lay on 2014/12/11.
 */
public class SwitchUtil {
    public static void close(Context context) {
        LogUtils.info("执行关闭");
        CommonUtils.showToast(context, "已为您关闭键盘灯");
        String[] cmds = {
                "chmod 666 /sys/class/leds/button-backlight/brightness",
                "echo 0 >/sys/class/leds/button-backlight/brightness",
                "chmod 444 /sys/class/leds/button-backlight/brightness"
        };
        System.out.println("修改配置：关闭");
        PreferencesUtil.put(context, PreferencesUtil.closeLight());
        ShellBuilder.execShell(cmds);

    }

    public static void open(Context context) {
        LogUtils.info("执行开启");
        CommonUtils.showToast(context, "已为您开启键盘灯");
        String[] cmds = {
                "chmod 666 /sys/class/leds/button-backlight/brightness",
                "echo 255 >/sys/class/leds/button-backlight/brightness",
                "chmod 444 /sys/class/leds/button-backlight/brightness"
        };
        System.out.println("修改配置：开启");
        PreferencesUtil.put(context, PreferencesUtil.openLight());
        ShellBuilder.execShell(cmds);
    }
}
